package com.yidu.t299.dao.zzy;

import com.yidu.t299.domain.zzy.*;
import com.yidu.t299.domain.zzy.Class;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @Author:周子怡
 * @Date:2023/03/21/11:42
 * @Description:
 */
@Mapper
public interface TeacherRemarkTwoMapper {

    /**
     * 根据校区编号查询指定的信息
     * @param remarkId 校区编号
     * @return 校区对象
     */
    @Select({
            "select" +
                    " remark_id,remark_effect,remark_practice,remark_context,teach_date,class_id,lesson_id,attitude,teacher_id" +
                    " from teacher_remark" +
                    " where remark_id = #{remarkId,jdbcType=INTEGER}"
    })
    @Results(id = "TeacherRemarkTwoMap",value = {
            @Result(id = true,column = "remark_id",property = "remarkId"),
            @Result(column = "remark_effect",property = "remarkEffect"),
            @Result(column = "remark_practice",property = "remarkPractice"),
            @Result(column = "remark_context",property = "remarkContext"),
            @Result(column = "teach_date",property = "teachDate"),
            @Result(column = "class_id",property = "classId"),
            @Result(column = "lesson_id",property = "lessonId"),
            @Result(column = "attitude",property = "attitude"),
            @Result(column = "teacher_id",property = "teacherId"),
    })
    TeacherRemarkTwo selectByPrimaryKey(Integer remarkId);

    /**
     * 按条件分页查询校区数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @return 校区对象集合
     */
    @Select("SELECT * \n" +
            "FROM teacher_remark tr \n" +
            "JOIN class c ON tr.class_id = c.class_id \n" +
            "JOIN record r ON tr.teacher_id = r.record_id \n" +
            "JOIN lesson l ON l.lesson_id = tr.lesson_id "+
            "limit #{page},#{rows}")
    @Results(id = "TeacherRemarkTwoJoinMap",value = {
            @Result(column = "remark_id",property = "remarkId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "remark_effect",property = "remarkEffect", jdbcType = JdbcType.VARCHAR),
            @Result(column = "remark_practice",property = "remarkPractice", jdbcType = JdbcType.VARCHAR),
            @Result(column = "remark_context",property = "remarkContext", jdbcType = JdbcType.VARCHAR),
            @Result(column = "teach_date",property = "teachDate", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_id",property = "classId", jdbcType = JdbcType.INTEGER),
            @Result(column = "lesson_id",property = "lessonId", jdbcType = JdbcType.INTEGER),
            @Result(column = "lesson_name",property = "lessonName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "lesson_times",property = "lessonTimes", jdbcType = JdbcType.INTEGER),
            @Result(column = "period_times",property = "periodTimes", jdbcType = JdbcType.INTEGER),
            @Result(column = "attitude",property = "attitude", jdbcType = JdbcType.VARCHAR),
            @Result(column = "teacher_id",property = "teacherId", jdbcType = JdbcType.INTEGER),
            @Result(column = "record_name",property = "recordName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_name",property = "className", jdbcType = JdbcType.VARCHAR)

    })
    List<TeacherRemarkTwo> selectByPage(@Param("rows") int rows, @Param("page") int page);
    /**
     * 按条件查询school表中数据行数
     * @return 数据行数
     */
    @Select("SELECT count(*) \n" +
            "FROM teacher_remark tr \n" +
            "JOIN class c ON tr.class_id = c.class_id \n" +
            "JOIN record r ON tr.teacher_id = r.record_id \n" +
            "JOIN lesson l ON l.lesson_id = tr.lesson_id ")
    int selectCount();

    /**
     * 针对班级表(class)进行操作
     * 根据学员名称查找其编号
     * @param className 学员名称
     * @return 影响的行数(>1:成功)
     */
    @Select("SELECT class_id FROM class WHERE class_name=#{className}")
    Integer selectByClassName(@Param("className") String className);

    /**
     * 针对班级表(class)进行操作
     * 根据学员名称查找其编号
     * @param recordName 学员名称
     * @return 影响的行数(>1:成功)
     */
    @Select("SELECT record_id FROM record WHERE record_name=#{recordName}")
    Integer selectByRecordName(@Param("recordName") String recordName);

    /**
     * 针对班级表(class)进行操作
     * 根据学员名称查找其编号
     * @param lessonTimes 学员名称
     * @return 影响的行数(>1:成功)
     */
    @Select("SELECT lesson_id FROM lesson WHERE lesson_times=#{lessonTimes}")
    Integer selectByLessonTimes(@Param("lessonTimes") Integer lessonTimes);

    /**
     * 针对班级表(class)进行操作
     * 根据学员名称查找其编号
     * @param periodTimes 学员名称
     * @return 影响的行数(>1:成功)
     */
    @Select("SELECT lesson_id FROM lesson WHERE period_times=#{periodTimes}")
    Integer selectByPeriodTimes(@Param("periodTimes") Integer periodTimes);

    /**
     * 针对班级表(class)进行操作
     * 根据学员名称查找其编号
     * @param lessonName 学员名称
     * @return 影响的行数(>1:成功)
     */
    @Select("SELECT lesson_id FROM lesson WHERE lesson_name=#{lessonName}")
    Integer selectByLessonName(@Param("lessonName") String lessonName);

    /**
     * 得到所有校区信息
     * @return 校区对象集合
     */
    @Select("select class_id,class_name from class")
    @Results({
            @Result(id = true,column = "class_id",property = "classId"),
            @Result(column = "class_name",property = "className")
    })
    List<Class> selectAllGetClass();

    /**
     * 得到所有课程信息
     * @return 课程对象集合
     */
    @Select("select record_id,record_name from record")
    @Results({
            @Result(id = true,column = "record_id",property = "recordId"),
            @Result(column = "record_name",property = "recordName"),
    })
    List<Record> selectAllGetRecord();

    /**
     * 得到所有课程信息
     * @return 课程对象集合
     */
    @Select("select lesson_id,lesson_name,lesson_times,period_times from lesson")
    @Results({
            @Result(id = true,column = "lesson_id",property = "lessonId"),
            @Result(column = "lesson_name",property = "lessonName"),
            @Result(column = "lesson_times",property = "lessonTimes"),
            @Result(column = "period_times",property = "periodName"),
    })
    List<Lesson> selectAllGetLesson();
}
